﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApp1
{
    public partial class MyButton : UserControl
    {
        public MyButton()
        {
            InitializeComponent();
            this.Paint += lblTips_Paint;
        }

        /// <summary>
        /// The BTN back color
        /// </summary>
        private Color _btnBackColor = Color.White;
        /// <summary>
        /// 按钮背景色
        /// </summary>
        /// <value>The color of the BTN back.</value>
        [Description("按钮背景色"), Category("自定义")]
        public Color BtnBackColor
        {
            get { return _btnBackColor; }
            set
            {
                _btnBackColor = value;
                this.BackColor = value;
            }
        }



        void lblTips_Paint(object sender, PaintEventArgs e)
        {
            e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;  //使绘图质量最高，即消除锯齿
            e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
            e.Graphics.CompositingQuality = CompositingQuality.HighQuality;

            e.Graphics.FillEllipse(new SolidBrush(this.label1.BackColor), new Rectangle(0, 0, label1.Width - 1, label1.Height - 1));
            System.Drawing.SizeF sizeEnd = e.Graphics.MeasureString("11", label1.Font);

            //e.Graphics.DrawString("11", label1.Font, new SolidBrush(label1.ForeColor), new PointF((label1.Width - sizeEnd.Width) / 2, (label1.Height - sizeEnd.Height) / 2 + 1));
        }
    }
}
